Allow decoding Tiff of different frame size. #2788
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Trim transparent pixels on image save?See the discussion in #1982
Decoding is fairly trivial. We just needed to pass the correct parameters to the various internal types and draw to frames matching the root frame dimensions.
I don't know whether it is actually possible to trim transparent pixels on encode as there's no guarantee that the pixel format we have decoded to supports transparency. I guess we could add some sort ofChromaKeyColor
property to the encoder and trim any bounding pixels matching that value?I'll likely need assistance writing a performant trimming algorithm (My SIMD is rusty)I've actually figured out a very neat way to handle all this transparently:
First off, we track the encoded dimensions in the same manner as ICO and CUR formats that ensures the frames are encoded at a configurable size.
By adding handling methods to the metadata APIs that run after processing a transformed image we can then automatically update those properties to scale with the transform. This mean you can load a Tiff Mipmap, resize the image and save each frame encoding only the relevant data!! 😄
In addition, I've normalized the
ImageFrame.Size()
method to now match theImage.Size
property.